#include <stdio.h>
//调整数组使奇数全部都位于偶数前面。

void fbda(int* arr, int len)
{
    int left = 0, right = len-1;
    while(left < right)
    {
        if((arr[left]%2 != 1)&&(arr[right]%2 == 1))//左偶右奇就交换
        {
            int k = arr[left];
            arr[left] = arr[right];
            arr[right] = k;
            left++;
            right--;
        }
        if(arr[left]%2 == 1)//左奇调整
        {
            left++;
        }
        if(arr[right]%2 != 1)//右偶调整
        {
            right--;
        }
    }
}

int main()
{
    int arr[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
    fbda(arr, 10);
    for(int i = 0; i < 10; i++)
    {
        printf("%d ", arr[i]);
    }
    return 0;
}